import { getUserAddressInfo, getTradeInfo } from '@/api'

const state = {
  userAddressInfo: [],
  tradeInfo: {},
}
const actions = {
  //获取用户地址数据
  async getUserAddressInfo(context, value) {
    let result = await getUserAddressInfo()
    if (result.code == '200') {
      context.commit('GETUSERADDRESSINFO', result.data)
    }
  },
  async getTradeInfo(context, value) {
    let result = await getTradeInfo()
    console.log(result)
    if (result.code == '200') {
      context.commit('GETTRADEINFO', result.data)
    }
  },
}
const mutations = {
  GETUSERADDRESSINFO(state, value) {
    state.userAddressInfo = value
  },
  GETTRADEINFO(state, value) {
    state.tradeInfo = value
  },
}
const getters = {}

export default {
  namespaced: 'trade',
  state,
  actions,
  mutations,
  getters,
}
